package com.whoisaa.wifitransfer.ui.adapter;

import android.app.Activity;
import android.view.View;

import com.whoisaa.wifitransfer.R;
import com.whoisaa.wifitransfer.WifiServerThread;
import com.whoisaa.wifitransfer.bean.ConnectedInfo;

import java.util.List;

/**
 * @Description
 * @Author AA
 * @DateTime 16/4/20 下午3:42
 */
public class ConnectedListAdapter extends CommonAdapter<ConnectedInfo> {

    private WifiServerThread mServerThread;


    public ConnectedListAdapter(Activity context, List<ConnectedInfo> datas, int itemLayoutId, WifiServerThread serverThread) {
        super(context, datas, itemLayoutId);
        this.mServerThread = serverThread;
    }

    @Override
    public void convert(ViewHolder holder, ConnectedInfo item) {
        holder.setText(R.id.tv_item_connected_ip, item.getMobileModel() + item.getIpAddress());
        holder.getView(R.id.btn_item_connected_send).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mServerThread != null) {
                    mServerThread.send();
                }
            }
        });

    }
}
